package demoMod.nanaki.patches;

import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import demoMod.nanaki.powers.NotePower;
import demoMod.nanaki.stances.AbstractStrophe;

public class AbstractMonsterPatch {
    /**
     * 实现处于诗节Ⅱ、Ⅲ时每次造成攻击伤害时给予目标音符的效果
     */
    @SpirePatch(
            clz = AbstractMonster.class,
            method = "damage"
    )
    public static class PatchDamage {
        public static void Prefix(AbstractMonster m, DamageInfo info) {
            if (info.type == DamageInfo.DamageType.NORMAL) {
                AbstractPlayer p = AbstractDungeon.player;
                if (p.stance instanceof AbstractStrophe) {
                    int stropheLevel = ((AbstractStrophe) p.stance).getStropheLevel();
                    if (stropheLevel > 1) {
                        AbstractDungeon.actionManager.addToTop(new ApplyPowerAction(m, p, new NotePower(m, stropheLevel - 1)));
                    }
                }
            }
        }
    }
}
